class Listener {
    constructor() {
        this.ctrl = {};
    }

    onMessage(message, sender, sendResponse) {
        if (this.ctrl[message.type]) {
            this.ctrl[message.type](message, sender, sendResponse);
        }
    }

    setHandle(type, callback) {
        this.ctrl[type] = callback;
    }
}